import { AxiosRequestConfig } from 'axios'
import { axiosApi } from '@/utils/request'

const UseRequest = async <T>(obj: AxiosRequestConfig) => {
  const data: Result<T> = await axiosApi.request({
    url: obj.url,
    method: obj.method,
    data: obj.data
  })
  const { result, message } = data
  const request: T = reactive<any>(result)
  return { request, message }
}
export default UseRequest
